package com.haima.sage.bigdata.api.frame.condition.expression.impl;

import com.haima.sage.bigdata.api.frame.condition.expression.BaseLogicService;

public class EmptyLogicService extends BaseLogicService {


    public EmptyLogicService(Object param) {
        super(param);
    }

    @Override
    public boolean logic(Object object) throws Exception {
        if (object == null) {
            return true;
        }
        // 文本需要特殊判断是否为空白字符
        if (object instanceof String) {
            return logic((String) object);
        } else if (object instanceof Character) {
            return logic((Character) object);
        }
        return false;
    }

    @Override
    public boolean logic(String objectparam) throws Exception {
        if (objectparam.length() == 0) {
            return true;
        }
        boolean res =  objectparam.trim().length() == 0;
        return res;
    }

    public boolean logic(Character objectparam) throws Exception {
        return Character.isWhitespace(objectparam);
    }
}
